<?php

require_once 'image.inc';

$fname = $_GET['name'];

if (!array_key_exists('original',$_GET))
{
	$thumb = new Thumbnail($fname, $_GET['width'], $_GET['height']);
	$fname = $thumb->path();
	
	if ($thumb->wasCreated() && array_key_exists('addMark',$_GET))	//add mark to newly created thumbnail
	{
		$orig = Image::loadFromFile($fname);
		$mark = Image::loadFromFile('/usr/local/apache/htdocs/images/mark.png');
		
		$mark->setColorTransparentAsAt(0,0);
		
		$orig->putWatermarkInCenter($mark, 60);
		$orig->saveToFile($fname);
	}
}

header('content-type: '.Image::getImageMime($fname));
readfile($fname);

?>